﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Dados.DSMPTUDOTableAdapters;

namespace Dados
{
    public class FormatoDAL
    {
        static T_FORMATOTableAdapter formatoTA = new T_FORMATOTableAdapter();

        public static DSMPTUDO.T_FORMATODataTable ConsultaTodos()
        {
            try
            {
                return formatoTA.GetData();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);

            }
        }
        public static DSMPTUDO.T_FORMATODataTable ConsultaPorCodigo(int codigo)
        {
            try
            {
                return formatoTA.GetFormatoPorCodigo(codigo);
            }
            catch(Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        public static bool Insere(string nome, int tipo)
        {
            try
            {
                if (formatoTA.Insert(nome, tipo) ==1) 
                    return true;
                else return false;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        public static bool Atualiza(string nome, int tipo, int codigo)
        {
            try
            {
                return (formatoTA.Update(nome, tipo,codigo,codigo) == 1);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }

            public static bool Remove(int codigo)
        {
            try
            {
                return (formatoTA.Delete(codigo) == 1);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }


    }
}
